package trangchu;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;

import chucnang.ButtonTabComponent;
import chucnang.DoanhThu;
import dangnhap.FromDangNhap;

import trogiup.FileServer;
import trogiup.HuongDanSuDung;
import trogiup.LienHe;
import trogiup.ThongTin;


public class TroGiup extends JPanel implements ActionListener {
	private JToolBar tbr;
    private JButton btnhuongdan,btnlienhe,btnthongtin;
    private TrangChu trangchu;
    private LienHe lienhe;
    private ThongTin thongtin;
    
    public TroGiup(TrangChu trangchu){
    	this.setLayout(new FlowLayout(FlowLayout.LEFT));
        this.trangchu = trangchu;
        this.tbr = new JToolBar();
        this.add(this.tbr);
        this.tbr.setOrientation(JToolBar.HORIZONTAL);
        this.btnhuongdan = new JButton("HD Sử Dụng",new ImageIcon(FromDangNhap.rootPath+"images/huongdan.gif"));
        this.btnhuongdan.setVerticalTextPosition(JButton.BOTTOM);
        this.btnhuongdan.setHorizontalTextPosition(JButton.CENTER);
        this.tbr.add(this.btnhuongdan);
        
        this.tbr.setOrientation(JToolBar.HORIZONTAL);
        this.btnlienhe = new JButton("Liên Hệ",new ImageIcon(FromDangNhap.rootPath+"images/lienhe.gif"));
        this.btnlienhe.setVerticalTextPosition(JButton.BOTTOM);
        this.btnlienhe.setHorizontalTextPosition(JButton.CENTER);
        this.tbr.add(this.btnlienhe);
        
        this.tbr.setOrientation(JToolBar.HORIZONTAL);
        this.btnthongtin = new JButton("Thông Tin",new ImageIcon(FromDangNhap.rootPath+"images/thongtin.gif"));
        this.btnthongtin.setVerticalTextPosition(JButton.BOTTOM);
        this.btnthongtin.setHorizontalTextPosition(JButton.CENTER);
        this.tbr.add(this.btnthongtin);
        
        
        // su kien
        this.btnhuongdan.addActionListener(this);
        this.btnlienhe.addActionListener(this);
        this.btnthongtin.addActionListener(this);
        
        lienhe = new LienHe(trangchu);
        thongtin = new ThongTin(trangchu);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
    	
    	
        if(e.getSource()== this.btnhuongdan){
//        	int index = this.trangchu.tbnPaneCenter.positionTab("Hướng Dẫn Sử Dụng");
//        	if(index > -1){	        		
//        		this.trangchu.tbnPaneCenter.setSelectedIndex(index);
//				return;
//			}else if(index == -1){
//				this.trangchu.tbnPaneCenter.addTab(new HuongDanSuDung(trangchu), "Hướng Dẫn Sử Dụng");
//				this.trangchu.tbnPaneCenter.setSelectedIndex( this.trangchu.tbnPaneCenter.getTabCount()-1);
//			}
        	new FileServer();
        }
        if(e.getSource()== this.btnlienhe){
        	lienhe.setVisible(true);        	 
        }
        if(e.getSource()== this.btnthongtin){
        	thongtin.setVisible(true);
        }
        int count = this.trangchu.tbnPaneCenter.getTabCount();
        for(int i=0;i<count;i++){
                this.trangchu.tbnPaneCenter.setTabComponentAt(i, new ButtonTabComponent(this.trangchu.tbnPaneCenter));

        }
    
    }
}
